package com.example.customizedgroupmessage;

import android.os.Bundle;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.view.*;
import android.widget.*;

public class SendCompletion extends Activity {

	//public static final int REQUEST_CODE_MAINACTIVITY=9999;
	DBHelper mHelper;
	SQLiteDatabase db;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.send_completion);
		
		mHelper = new DBHelper(getBaseContext());
		db = mHelper.getWritableDatabase();
		
		db.execSQL("DELETE FROM sms;");
		db.execSQL("DELETE FROM mail;");
		mHelper.close();
		
		// 메인으로
		Button btnGoMain = (Button)findViewById(R.id.btnGoMain);
		btnGoMain.setOnClickListener(new Button.OnClickListener() {
			public void onClick(View v){
				Intent intent = new Intent(SendCompletion.this, MainActivity.class);
				intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
				startActivity(intent);
			}
		});
		
		// 앱 종료
		Button btnExit = (Button)findViewById(R.id.btnExit);
		btnExit.setOnClickListener(new Button.OnClickListener() {
			public void onClick(View v){
				moveTaskToBack(true);
				finish();
				ActivityManager am = (ActivityManager)getSystemService(ACTIVITY_SERVICE);
				am.restartPackage(getPackageName());
				android.os.Process.killProcess(android.os.Process.myPid());
			}
		});
	}
}
